import http from "@/api";
import { ResPage, SelectOptionResult } from "@/api/interface";
import {
  CreateRoleParam,
  EditRoleInfoParam,
  EditRoleStatusParam,
  GetRoleDetailParam,
  GetRoleListParam,
  RoleDetailResult,
  SysRole
} from "@/api/interface/auth/role";

const apiName = "RoleManager";

/** 创建角色 */
export const createRole = (param: CreateRoleParam) => {
  return http.post<string>(`${apiName}/CreateRole`, param);
};

/** 获取角色列表选项（下拉选项用） */
export const getRoleOptions = () => {
  return http.post<SelectOptionResult[]>(`${apiName}/GetRoleOptions`);
};

/** 获取角色列表 */
export const getRoleList = (param: GetRoleListParam) => {
  return http.post<ResPage<SysRole>>(`${apiName}/GetRoleList`, param);
};

/** 获取角色详情 */
export const getRoleDetail = (param: GetRoleDetailParam) => {
  return http.post<RoleDetailResult>(`${apiName}/GetRoleDetail`, param);
};
/** 修改角色信息 */
export const editRoleInfo = (param: EditRoleInfoParam) => {
  return http.post<string>(`${apiName}/EditRoleInfo`, param);
};

/** 修改角色状态 */
export const editRoleStatus = (param: EditRoleStatusParam) => {
  return http.post<string>(`${apiName}/EditRoleStatus`, param);
};
